package com.bulemobi.activity.ac_user_centre;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.bulemobi.activity.ac_login.Ac_Login;
import com.bulemobi.data.DataCentre;
import com.bulemobi.net.tsz.afinal.FinalHttp;
import com.bulemobi.net.tsz.afinal.annotation.view.ViewInject;
import com.bulemobi.net.tsz.afinal.http.AjaxCallBack;
import com.bulemobi.net.tsz.afinal.http.AjaxParams;
import com.bulemobi.urlCentre.UrlCentre;
import com.bulemobi.view.AddMyBank;
import com.bulemobi.view.BaseActivity;
import com.bulemobi.view.titleView.ActionBarView;
import com.jsyh.hcb.R;

/**
 * @author zengys  我的银行卡
 *         <p/>
 *         <p/>
 *         2014年9月18日 17:25:03
 */
public class Ac_MyBankActivity extends BaseActivity implements OnClickListener {

    AddMyBank view;
//   listview item 已完
    @ViewInject(id = R.id.btn_add_bank_confirm)
    Button btn_add_bank_confirm;
    @ViewInject(id = R.id.actionBar)
    ActionBarView actionBarView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ac_my_bank);
        initView();
//        查询银行卡
        qryList();
    }

    private void qryList(){
        AjaxParams params = new AjaxParams();
        params.put("TerminalType", UrlCentre.TerminalType);
        params.put("UserType", UrlCentre.UserType);
        params.put("ChannelId", UrlCentre.ChannelId);
        requestHttp(UrlCentre.ActMyBankListQry,params,"qry");
    }

    private void initView(){
        btn_add_bank_confirm.setOnClickListener(this);
        actionBarView.setTitle(getResources().getString(R.string.ac_bundling_card_title));
    }

    private void requestHttp(String url,AjaxParams params, final String type){
        FinalHttp http = new FinalHttp();
        http.post(url,params,new AjaxCallBack<Object>() {
            @Override
            public void onStart() {
                showProgressDialog();
                super.onStart();
            }

            @Override
            public void onSuccess(Object o) {
                closeProgressDialog();
//                查询信息
                if(type.equals("qry")){

                }
                super.onSuccess(o);
            }

            @Override
            public void onFailure(Throwable t, int errorNo, String strMsg) {
                closeProgressDialog();
                super.onFailure(t, errorNo, strMsg);
            }
        });
    }

    private boolean checkLogin(){
        if(TextUtils.isEmpty(DataCentre.sessionId)){
            return false;
        }else {
            return true;
        }
    }


    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()){
            case R.id.btn_add_bank_confirm:
                if(checkLogin()){
                    openActivity(AcBundlingCard.class);
                    finish();
                }else{
                    showToastShort("你还未登入..");
                    openActivity(Ac_Login.class);
                    finish();
                    return;
                }
                break;
        }
    }
}
